<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>招标发布</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
<%--    <script type="text/javascript" src="/js/common/fileupload.js"></script>--%>
    <script type="text/javascript" src="/js/email/fileuploadPlus.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    * {font-family: "Microsoft Yahei" !important;}
    .header{
        margin-top: 15px;
        height: 78px;
        margin: 20px;
    }
    .header .title{
        margin-left: 22px;
    }
    .header span{
        float: none;
        font-size: 22px;
        color: #333;
        display: inline-block;
        margin-left: 10px;
        vertical-align: middle;
        margin-top: -6px;
    }
    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
    #ajaxforms .layui-form-item .layui-inline{
        margin-bottom: -5px !important;
    }
    .addExecute{
        display: inline-block;
        margin-top:10px;
    }
    .adduser{
        display: inline-block;
        margin-top:37px;
    }

    #ajaxforms .layui-form-label{
        width: 98px;
    }
    .layui-btn+.layui-btn {
        margin-left: 6px;
    }
    .layui-form-label{
        float: left;
        display: block;
        padding: 9px 0px;
         width: 30px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
        padding-right: 10px;
    }
</style>
<body>
<div>
    <div class="header">
        <div class="title">
            <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">招标发布</span>
            <hr style="background-color: black"/>
        </div>
        <div style="margin: auto 20px;">
            <form class="layui-form" action="">
                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <select name="status" lay-verify="required">
                            <option value="">请选择</option>
                            <option value="1">未发布</option>
                            <option value="2">已发布</option>
                            <option value="3">开标中</option>
                            <option value="4">结束</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin: auto 15px">
                    <label class="layui-form-label">年度</label>
                    <div class="layui-input-inline">
                        <input type="text" lay-verify="required|phone" autocomplete="off" class="layui-input projectYear">
                    </div>
                </div>
                <button type="button" class="layui-btn search">查询</button>
                <button type="button" class="layui-btn  information" style="float: right;display: none">发布项目</button>
                <button type="button" class="layui-btn layui-btn-warm add" style="float: right;">新建</button>
            </form>
        </div>
    </div>
    <input type="text" style="display: none" id="modifyDate">
    <div style="margin: auto 36px">
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>
</body>
</html>
<script type="text/html" id="barDemo">
    {{#  if(d.status == 1){ }}
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="opening">发布</a>
    {{#  } }}

    {{#  if(d.status == 2){ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs  layui-btn-warm" lay-event="bidOpening">项目开标</a>
    {{#  } }}

    {{#  if(d.status == 1){ }}
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    {{#  } }}

    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="look">查看投标</a>

    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>

</script>

<script>
    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var form = layui.form
            ,table =layui.table
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        form.render()
        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#modifyDate',// input里时间的Id
            value: new Date(),
            done: function (value, date) {
            }
        });
        var tableInt = table.render({
            elem: '#test'
            ,url:'/biddingInfo/getBiddingInfo'
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code":0, //解析接口状态
                    "data": res.obj, //解析数据列表，
                    "count": res.totleNum, //解析数据长度
                };
            }
            ,cols: [[
                // {type:'checkbox'},
                {field:'projectNo', title:'项目编号'}
                ,{field:'projectName', title:'项目名称'}
                ,{field:'projectYear', title:'项目年度'}
                ,{field:'purchaseDeptName', title:'采购部门'}
                ,{field:'infoDesc', title:'详细要求'}
                ,{field:'releaseDate', title:'发布日期'}
                ,{field:'biddingBeginDate', title:'投标开始日期'}
                ,{field:'biddingEndDate', title:'投标结束日期'}
                ,{field:'attachmentName', title:'招标文件'}
                ,{field:'status', title:'状态',templet: function (d) {
                        // console.log(d)
                        var status = d.status
                        if(status == 1){
                            return status = '未发布'
                        }else if(status == 2){
                            return status = '已发布'
                        }else if(status == 3){
                            return status = '开标中'
                        }else {
                            return status = '结束'
                        }
                    }}
                ,{fixed: '', title:'操作', toolbar: '#barDemo',width:250,align:'center',width:290}
            ]]
            ,page: true
        });

        //新建
        $('.add').click(function () {
            creat(0)
        });
        //点击发布信息按钮
        $('.information').click(function(){
            var chooseArr = layui.table.checkStatus('test').data;
            if(chooseArr.length == 0){
                layer.alert('请至少选择一个项目！', {icon: 7})
            }else {
                var biddingId = ''
                for (var i = 0; i < chooseArr.length; i++) {
                    biddingId += chooseArr[i].biddingId + ','
                }
                $.ajax({
                    type:'post',
                    url:'/biddingInfo/releaseBidding',
                    dataType:'json',
                    data: {
                        biddingIds: biddingId
                    },
                    success:function(res){
                        layer.alert('发布成功！', {icon: 1})
                        tableInt.reload()
                        // layer.closeAll();
                    }
                })
            }
                //

        })
        // var chooseArr = layui.table.checkStatus('test').data;

        /*新建和编辑的方法*/
        function creat(type, biddingId) {
            if (type == '0') {
                var title = '新建';
            } else {
                var title = '编辑';
            }

            layer.open({
                type: 1,
                title: title,
                btn: ['确定','返回'],
                shade: 0.5,
                area: ['40%', '70%'],
                content: '<div id="cont" style="margin: 10px">\n' +
                    '        <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <label class="layui-form-label">项目编号：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="projectNo" lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <label class="layui-form-label">项目名称：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="projectName" lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                  <label class="layui-form-label">项目年度：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="projectYear" lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '               <div class="layui-inline">\n' +
                    '                    <label class="layui-form-label">投标人：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <textarea  type="text" id="rescueUser"  user_id=""  class="layui-textarea" disabled>\n' +
                    '                    </textarea></div>\n' +
                    '                    <a href="javascript:;" style="color:#1E9FFF" class="adduser">添加</a>\n' +
                    '                    <a href="javascript:;" style="color:red" class="clearuser">清空</a>\n' +
                    '                </div>\n'+
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <div class="layui-inline">\n' +
                    '                    <label class="layui-form-label">采购部门：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" id="deptNames" lay-verify="url" autocomplete="off" class="layui-input" disabled>\n' +
                    '                    </div>\n' +
                    '                    <a href="javascript:;" style="color:#1E9FFF" class="addExecute">添加</a>\n' +
                    '                    <a href="javascript:;" style="color:red" class="clearExecute">清空</a>\n' +
                    '                </div>\n'+
                    '            </div>\n' +
                    '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                    '                <div class="layui-inline">\n' +
                    '                   <label class="layui-form-label">详细要求：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <textarea type="text" name="infoDesc" lay-verify="required|phone" autocomplete="off"\n' +
                    '                               class="layui-input required"></textarea>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <div class="layui-inline">\n' +
                    '                  <label class="layui-form-label">投标开始日期：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="biddingBeginDate" id="dateStart" lay-verify="date"\n' +
                    '                               autocomplete="off" class="layui-input required">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <div class="layui-inline">\n' +
                    '                    <label class="layui-form-label">投标结束日期：</label>\n' +
                    '                    <div class="layui-input-inline">\n' +
                    '                        <input type="text" name="biddingEndDate" id="dateEnd" lay-verify="date"\n' +
                    '                               autocomplete="off" class="layui-input required">\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    ' <div class="layui-form-item"  style="margin-top:15px">\n' +
                    '    <label class="layui-form-label">招标文件：</label>\n' +
                    '    <div class="layui-input-inline">\n' +
                    '<div id="fujians"></div>' +
                    ' <div id="fileAll">\n' +
                    '</div>\n' +
                    '<a href="javascript:;" class="openFile" style="float: left;margin-top:8px;position:relative">\n' +
                    '<img src="../img/mg11.png" alt="">\n' +
                    '<span>添加附件</span>\n' +
                    '<input type="file" multiple id="fileupload" data-url="/upload?module=certification" name="file">\n' +
                    '</a>\n' +
                    '</div>\n' +
                    '</div>' +
                    '        </form>\n' +
                    '    </div>',
                success:function (res) {
                    //日期
                    laydate.render({
                        elem: '#year'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'year'
                    });
                    laydate.render({
                        elem: '#date'
                        , trigger: 'click'//呼出事件改成click
                    });
                    laydate.render({
                        elem: '#dateStart'
                        , trigger: 'click'//呼出事件改成click
                    });
                    laydate.render({
                        elem: '#dateEnd'
                        , trigger: 'click'//呼出事件改成click
                    });
                    form.render();

                    //采购部门点击添加的按钮
                    $(".addExecute").on("click",function(){
                        dept_id = "deptNames";
                        $.popWindow("/common/selectDept?0");
                    });

                    $('.clearExecute').click(function () {
                        $('#deptNames').attr("deptid", "");
                        $('#deptNames').attr("deptno", "");
                        $('#deptNames').attr("deptname", "");
                        $('#deptNames').val("");
                    });

                    //进货人点击添加的按钮
                    $(".adduser").on("click",function(){
                        user_id = "rescueUser";
                        $.popWindow("/common/selectUser");
                    });

                    $('.clearuser').click(function () {
                        $("#rescueUser").val("");
                        $("#rescueUser").attr('username','');
                        $("#rescueUser").attr('dataid','');
                        $("#rescueUser").attr('user_id','');
                        $("#rescueUser").attr('userprivname','');
                    });
                    fileuploadFn('#fileupload', $('#fileAll'));

                    <%--$('#wordimportfile').fileupload({--%>
                    <%--    dataType:'json',--%>
                    <%--    done: function (e, data) {--%>
                    <%--        if(data.result.obj != ''){--%>
                    <%--            var data = data.result.obj;--%>
                    <%--            var str = '';--%>
                    <%--            var str1 = '';--%>

                    <%--            for (var i = 0; i < data.length; i++) {--%>
                    <%--                var gs = data[i].attachName.split('.')[1];--%>
                    <%--                if(gs == 'jsp'||gs == 'css'||gs == 'js'||gs == 'html'||gs == 'java'||gs == 'php'||gs == 'xls'||gs == 'xlsx' ){--%>
                    <%--                    str += '';--%>
                    <%--                    layer.alert('jsp、css、js、html、java文件禁止上传!',{},function(){--%>
                    <%--                        layer.closeAll();--%>
                    <%--                    });--%>
                    <%--                }else{--%>
                    <%--                    str+='<div class="dech" deUrl="'+encodeURI(data[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" NAME="'+data[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(data[i].attUrl)+'">'+data[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" NAME="'+data[i].attachName+'*"  class="inHidden" value="'+data[i].aid+'@'+data[i].ym+'_'+data[i].attachId+',"></div>';--%>
                    <%--                }--%>
                    <%--                &lt;%&ndash;if(gs != 'doc' ){&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;str += '';&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;layer.alert('jsp、css、js、html、java文件禁止上传!',{},function(){&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;layer.closeAll();&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;});&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;}else{&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;str+='<div class="dech" deUrl="'+encodeURI(data[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" NAME="'+data[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(data[i].attUrl)+'">'+data[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" NAME="'+data[i].attachName+'*"  class="inHidden" value="'+data[i].aid+'@'+data[i].ym+'_'+data[i].attachId+',"></div>';&ndash;%&gt;--%>
                    <%--                &lt;%&ndash;}&ndash;%&gt;--%>
                    <%--            }--%>
                    <%--            // $('#query_uploadArr').append(str);--%>
                    <%--            // $('#query_uploadArr').val();--%>
                    <%--        } else{--%>
                    <%--            //alert('添加附件大小不能为空!');--%>
                    <%--            layer.alert('添加附件大小不能为空!',{},function(){--%>
                    <%--                layer.closeAll();--%>
                    <%--            });--%>
                    <%--        }--%>
                    <%--    }--%>
                    <%--});--%>
                    //编辑
                    if(type==1){
                        $.ajax({
                            url:'/biddingInfo/getBiddingInfo',
                            dataType: 'json',
                            type: 'get',
                            data:{
                                biddingId:biddingId
                            },
                            success:function (res) {
                                var str = ''
                                form.render()
                                var  attachmentList = res.obj[0].attachmentList
                                if(attachmentList !=undefined && attachmentList.length>0){
                                    for(var i=0;i<res.obj[0].attachmentList.length;i++){
                                        str+='<div class="dech" deUrl="' +res.obj[0].attachmentList[i].attUrl + '"><a href="/download?' + res.obj[0].attachmentList[i].attUrl + '" NAME="' + res.obj[0].attachmentList[i].attachName +'*"><img style="margin-right:10px;" src="/img/attachment_icon.png"/>' + res.obj[0].attachmentList[i].attachName + '</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/><input type="hidden" class="inHidden" value="' + res.obj[0].attachmentList[i].aid + '@' + res.obj[0].attachmentList[i].ym + '_' + res.obj[0].attachmentList[i].attachId +',"></div>'
                                    }
                                }else{
                                    str='';
                                }
                                $('#fujians').html(str)
                                $('#rescueUser').val(res.obj[0].tenderUserName)
                                $("#rescueUser").attr('user_id',res.obj[0].tenderUserid);

                                $('#deptNames').val(res.obj[0].purchaseDeptName)
                                $("#deptNames").attr('deptid',res.obj[0].purchaseDeptid);
                                form.val("ajaxforms", res.obj[0]);
                            }

                        })
                    }
                },
                yes:function (index) {
                    var obj = {}
                    console.log(type)
                    if(type == 1){
                        var attachmentId = '';
                        var attachmentName = '';
                        for (var i = 0; i < $('#fujians .dech').length; i++) {
                            attachmentId += $('#fujians .dech').eq(i).find('input').val();
                            attachmentName += $('#fujians a').eq(i).attr('name');
                        }
                        for (var i = 0; i < $('#fileAll .dech').length; i++) {
                            attachmentId += $('#fileAll .dech').eq(i).find('input').val();
                            attachmentName += $('#fileAll a').eq(i).attr('name');
                        }
                    }else {
                        // 附件fujians
                        var attachmentId = '';
                        var attachmentName = '';
                        for (var i = 0; i < $('#fileAll .dech').length; i++) {
                            attachmentId += $('#fileAll .dech').eq(i).find('input').val();
                            attachmentName += $('#fileAll a').eq(i).attr('name');
                        }
                    }

                    if(type == 0){
                        var url = '/biddingInfo/editBiddingInfo'
                    }else{
                        var url = '/biddingInfo/editBiddingInfo'
                        obj.biddingId = biddingId
                    }
                    var purchaseDeptid = ''

                    if($('#deptNames').attr('deptid') != undefined){
                        purchaseDeptid = $('#deptNames').attr('deptid').substr(0,$('#deptNames').attr('deptid').length-1)
                    }
                    obj.purchaseDeptid = purchaseDeptid
                    obj.projectNo = $('input[name="projectNo"]').val()
                    obj.projectName = $('input[name="projectName"]').val()
                    obj.projectYear =$('input[name="projectYear"]').val()
                    obj.tenderUserid = $('#rescueUser').attr('user_id')
                    obj.infoDesc = $('textarea[name="infoDesc"]').val()
                    // obj.releaseDate = $('#date').val()
                    obj.biddingBeginDate = $('#dateStart').val()
                    obj.biddingEndDate = $('#dateEnd').val()
                    obj.attachmentId = attachmentId
                    obj.attachmentName =attachmentName
                    obj.status = 1

                    if($('input[name="projectNo"]').val() == ''){
                        layer.msg('请输入项目编号！', {icon: 2});
                        return false
                    }else if($('input[name="projectName"]').val() == ''){
                        layer.msg('请输入项目名称！', {icon: 2});
                        return false
                    }else if($('input[name="projectYear"]').val() == ''){
                        layer.msg('请输入项目年度！', {icon: 2});
                        return false
                    }else if($('#rescueUser').attr('user_id') == ''){
                        layer.msg('请选择投标人！', {icon: 2});
                        return false
                    }
                    $.ajax({
                        url: url,
                        dataType: 'json',
                        type: 'post',
                        data: obj,
                        success: function (res) {
                            if (res.flag) {
                                layer.msg('新增成功！', {icon: 1});
                                // tableInt.reload()
                                window.location.reload()
                                layer.closeAll();
                            }
                        }
                    })
                }
            })
        }

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            var biddingId = data.biddingId
            if(obj.event === 'edit'){
                creat(1,biddingId)
            }else if(obj.event === 'del'){
                layer.confirm('真的删除当前数据吗？', function (index) {
                    $.ajax({
                        type: 'get',
                        url: '/biddingInfo/delBiddingInfo?biddingId='+biddingId,
                        dataType: 'json',
                        success: function (res) {
                            if (res.msg == 'ok') {
                                layer.msg('删除成功！', {icon: 1});
                                // tableInt.reload()
                                window.location.reload()
                                layer.closeAll();
                            }
                        }
                    })
                });
            }else if (obj.event === 'look'){
                var biddingId = data.biddingId
                layer.open({
                    type: 1 //Page层类型
                    , area: ['80%', '80%']
                    , title: '查看投标'
                    , content: '<div class="layui-form" id="findStock" style="margin:10px 20px">' +
                        '<table class="layui-hide" id="store" lay-filter="store"></table>\n'+
                        '</div>'
                    , btn: ['返回']
                    ,success:function(res){
                      table.render({
                            elem: '#store',
                            url:' /TenderInfo/getTenderInfo',
                            where:{
                                biddingId:biddingId
                            },
                            parseData: function(res){ //res 即为原始返回的数据
                                return {
                                    "code":0, //解析接口状态
                                    "data": res.obj, //解析数据列表，
                                    // "count": res.totleNum, //解析数据长度
                                };
                            },
                            cols: [[
                                {field:'projectNo', title:'项目编号',templet:function(d){
                                    if(d.crmBiddingInfo != undefined){
                                        return d.crmBiddingInfo.projectNo
                                    }else {
                                        return ''
                                    }

                                    }}
                                ,{field:'projectName', title:'项目名称',templet:function(d){
                                        if(d.crmBiddingInfo != undefined) {
                                            return d.crmBiddingInfo.projectName
                                        }else {
                                            return  ''
                                        }
                                    }}
                                ,{field:'userName', title:'供货商'}
                                ,{field:'tenderStatus', title:'投标状态',templet:function(d){
                                        var tenderStatus = d.tenderStatus
                                        if(tenderStatus == 0){
                                            return '未查看'
                                        }else if(tenderStatus == 1){
                                            return '未完成'
                                        }else {
                                            return '完成'
                                        }
                                    }}
                                ,{field:'biddingEndDate', title:'完成投标日期',templet:function(d){
                                    return d.crmBiddingInfo.biddingEndDate
                                    }}
                                ,{field:'attachmentName', title:'投标文件'}
                                ,{field:'hitStatus', title:'中标状态',templet: function (d) {
                                        // console.log(d)
                                        var hitStatus = d.hitStatus
                                        if(hitStatus == '0'){
                                            return hitStatus = '待定'
                                        }else if(hitStatus == '1'){
                                            return hitStatus = '中标'
                                        }else {
                                            return hitStatus = '未中标'
                                        }
                                    }}
                            ]]
                            ,page: false,
                        });
                    }
                });
            }else if(obj.event === 'opening'){
                var biddingId = data.biddingId
                $.ajax({
                    type:'post',
                    url:'/biddingInfo/editBiddingInfo',
                    dataType:'json',
                    data: {
                        biddingId: biddingId,
                        status:2,
                        releaseUserid:'admin',
                        releaseDate:$('#modifyDate').val()
                    },
                    success:function(res){
                        layer.alert('发布成功！', {icon: 1})
                        // tableInt.reload()
                        window.location.reload()
                        // layer.closeAll();
                    }
                })
            }else if(obj.event == 'bidOpening'){
                $.ajax({
                    type:'post',
                    url:'/biddingInfo/editBiddingInfo',
                    dataType:'json',
                    data: {
                        biddingId: biddingId,
                        status:3
                    },
                    success:function(res){
                        layer.alert('项目开标！', {icon: 1})
                        tableInt.reload()
                        window.location.reload()
                        // layer.closeAll();
                    }
                })
            }
        });
        //删除附件
        $(document).on('click', '.deImgs', function () {
            var _this = this;
            var attUrl = $(this).parents('.dech').attr('deUrl');
            layer.confirm('确定删除该附件吗？', function (index) {
                $.ajax({
                    type: 'get',
                    url: '/delete?' + attUrl,
                    dataType: 'json',
                    success: function (res) {

                        if (res.flag == true) {
                            layer.msg('删除成功', {icon: 6, time: 1000});
                            $(_this).parent().remove();

                        } else {
                            layer.msg('删除失败', {icon: 2, time: 1000});
                        }
                    }
                })
            });
        });
        $('.search').click(function(){
            tableInt.reload({
                url:'/biddingInfo/getBiddingInfo',
                where:{
                    status:$('select[name="status"]').val(),
                    projectYear:$('.projectYear').val()
                }
                ,page: {
                    curr: 1
                }
            });
        })

    });
</script>
